package com.leyou.item.client;

import com.leyou.common.vo.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author: guojy
 * @date: 2020/3/6 19:15
 * @Description: 用于向外暴露方法
 * @version: 1.0
 */
@FeignClient("item-service")
public interface ItemClient {
    //TODO 一：商品信分页查询spu
    //TODO 二：根据spuId查询sku
    //TODO 三：根据spuId查询SpuDetail
    //TODO 四：根据商品多级分类id，查询商品分类
    //TODO 五：查询分类下可以用来搜索的规格参数 searching字段
    //TODO 六：根据品牌id查询品牌
    //TODO 七、根据品牌id批量查询品牌
    //TODO 八、根据 spuid，查询spu对象

    //TODO 一：商品信分页查询spu
    @GetMapping("/spu/page")
    PageResult<SpuDTO> findSpuByPage1(
            @RequestParam(name = "page", defaultValue = "1") Integer page,
            @RequestParam(name = "rows", defaultValue = "5") Integer rows,
            @RequestParam(name = "key", required = false) String key,
            @RequestParam(name = "saleable", required = false) Boolean saleable);

    //TODO 三：根据spuId查询SpuDetail
    @GetMapping("/spu/detail")
    SpuDetailDTO findSpuDetailBySpuId(@RequestParam(name = "id") Long id);
    //SpuDetailDTO findSpuDetailBySpuId(Long id);

    //TODO 三：根据spuId查询SpuDetail
    @GetMapping("sku/of/spu")
    List<SkuDTO> findSkusBySpuId(@RequestParam(name = "id") Long spuId);

    //TODO 四：根据商品多级分类id，查询商品分类
    @GetMapping("/category/list")
    List<CategoryDTO> findCategoryByIds(@RequestParam(name = "ids") List<Long> ids);

    //TODO 五：查询分类下可以用来搜索的规格参数 searching字段
    @GetMapping("/spec/params")
    List<SpecParamDTO> findSpecParam(
            @RequestParam(name = "gid", required = false) Long groupId,
            @RequestParam(value = "cid", required = false) Long cid,
            @RequestParam(value = "searching", required = false) Boolean searching);

    //TODO 六：根据品牌id查询品牌
    @GetMapping("/brand/{id}")
    BrandDTO findBrandById(@PathVariable(name = "id") Long id);

    /**
     * // TODO 七、根据品牌id批量查询品牌
     *
     * @param idList 品牌id的集合
     * @return 品牌的集合
     */
    @GetMapping("/brand/list")
    List<BrandDTO> findBrandsByIds(@RequestParam("ids") List<Long> idList);

    /**
     * //TODO 八、根据 spuid，查询spu对象
     *
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
    SpuDTO findSpuById(@PathVariable("id") Long id);

    /**
     * @param cateoryId
     * @return
     */
    @GetMapping("spec/groups/of/category")
    List<SpecGroupDTO> findSpecGroupByCategoryId(
            @RequestParam(name = "id") Long cateoryId);

}
